package ink.lovejinhu.swardToOffer;

import ink.lovejinhu.common.ListNode;

/**
 * @author jinhu
 * created 2021-08-09 8:37
 */
public class Offer_024 {
    /**
     * 反转链表
     * 扩展题目：逆置链表位置N到M之间的节点
     *
     * @param head
     * @return
     */
    public ListNode reverseList(ListNode head) {
        ListNode new_head = null;
        while (head != null) {
            ListNode temp = head.next;
            head.next = new_head;
            new_head = head;
            head = temp;
        }
        return new_head;
    }
}
